<html>
<head><meta charset="utf-8"><title>What&#x27;s the deal with importing builtin attributes? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What&#x27;s.20the.20deal.20with.20importing.20builtin.20attributes.3F.html">What&#x27;s the deal with importing builtin attributes?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="205027336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%27s%20the%20deal%20with%20importing%20builtin%20attributes%3F/near/205027336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What&#x27;s.20the.20deal.20with.20importing.20builtin.20attributes.3F.html#205027336">(Jul 25 2020 at 23:52)</a>:</h4>
<p>This is valid Rust code:</p>
<div class="codehilite"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">use</span><span class="w"> </span><span class="n">inline</span><span class="p">;</span><span class="w"></span>
</code></pre></div>


<p>It reexports the <code>#[inline]</code> attribute. Builtin attributes cannot actually be used through this though. It also seems that they reside in the macro namespace, despite not really being macros.</p>
<p>What's the deal with this odd feature? Is this documented anywhere? What <em>can</em> I do with this?</p>



<a name="205031906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%27s%20the%20deal%20with%20importing%20builtin%20attributes%3F/near/205031906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What&#x27;s.20the.20deal.20with.20importing.20builtin.20attributes.3F.html#205031906">(Jul 26 2020 at 02:25)</a>:</h4>
<p>file an issue ccing petrochenkov</p>



<a name="205041723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%27s%20the%20deal%20with%20importing%20builtin%20attributes%3F/near/205041723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What&#x27;s.20the.20deal.20with.20importing.20builtin.20attributes.3F.html#205041723">(Jul 26 2020 at 08:05)</a>:</h4>
<p>This is just a consequence of uniform import paths - you can import any name that is in scope.</p>



<a name="205041727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%27s%20the%20deal%20with%20importing%20builtin%20attributes%3F/near/205041727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What&#x27;s.20the.20deal.20with.20importing.20builtin.20attributes.3F.html#205041727">(Jul 26 2020 at 08:05)</a>:</h4>
<p><code>inline</code> is in scope in macro namespace.</p>



<a name="205041827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%27s%20the%20deal%20with%20importing%20builtin%20attributes%3F/near/205041827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What&#x27;s.20the.20deal.20with.20importing.20builtin.20attributes.3F.html#205041827">(Jul 26 2020 at 08:08)</a>:</h4>
<p>Making the <code>use inline;</code> itself an error is too strict because <code>inline</code> can mean something reasonable in other, non-macro namespaces.<br>
See e.g. <a href="https://github.com/rust-lang/rust/issues/56326">#56326</a> and other issues linked from <a href="https://github.com/rust-lang/rust/pull/56759">https://github.com/rust-lang/rust/pull/56759</a>.</p>



<a name="205041887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%27s%20the%20deal%20with%20importing%20builtin%20attributes%3F/near/205041887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What&#x27;s.20the.20deal.20with.20importing.20builtin.20attributes.3F.html#205041887">(Jul 26 2020 at 08:11)</a>:</h4>
<p>And actual use of built-in attributes through reexports is prohibited because the built-in attribute detection is often done through silly textual match (<code>name == sym::inline</code>) rather than through name resolution, so <code>use inline as inline2</code> + <code>#[inline2]</code> won't be detected as a use of the <code>inline</code> attribute.</p>



<a name="205046108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%27s%20the%20deal%20with%20importing%20builtin%20attributes%3F/near/205046108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What&#x27;s.20the.20deal.20with.20importing.20builtin.20attributes.3F.html#205046108">(Jul 26 2020 at 10:26)</a>:</h4>
<p>Ah, I see. Thanks for the explanation!</p>



<a name="205307490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%27s%20the%20deal%20with%20importing%20builtin%20attributes%3F/near/205307490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> alercah <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What&#x27;s.20the.20deal.20with.20importing.20builtin.20attributes.3F.html#205307490">(Jul 29 2020 at 00:47)</a>:</h4>
<p>Attributes live in the macro namespace. That much, at least, is expected.</p>



<a name="205307551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%27s%20the%20deal%20with%20importing%20builtin%20attributes%3F/near/205307551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> alercah <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What&#x27;s.20the.20deal.20with.20importing.20builtin.20attributes.3F.html#205307551">(Jul 29 2020 at 00:48)</a>:</h4>
<p>(because proc macros)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>